package com.guigu.vo;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.Serializable;
import java.util.List;

@Data//代表getter,setter
@AllArgsConstructor//有参构造
@NoArgsConstructor//无参构造
@ToString//tosstring的注解
public class tjPackageVO implements Serializable {

    private static final long serialVersionUID = -2745990289020514752L;

    private String packagecoding;
    private String packagename;
    private String mnemonicname;
    private String applytogender;
    private String agesx;
    private String agexx;
    private String packageprice;
    private String introduce;
    private String note;
    private MultipartFile file;
    private String checkitemVO; // 使用String类型接收CheckitemVO
    private String checkgroupVO; // 使用String类型接收CheckgroupVO

    public List<CheckitemVO> getCheckitemVOList() {
        // 将checkitemVO字符串转换为List<CheckitemVO>
        // 示例代码：使用Jackson库进行转换
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.readValue(checkitemVO, new TypeReference<List<CheckitemVO>>() {});
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public List<CheckgroupVO> getCheckgroupVOList() {
        // 将checkitemVO字符串转换为List<CheckitemVO>
        // 示例代码：使用Jackson库进行转换
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.readValue(checkgroupVO, new TypeReference<List<CheckgroupVO>>() {});
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

}
